﻿using UnityEngine;
using System.Collections;

public class LaunchValidator : MonoBehaviour {
	
	
	public UIInput nicknameInput;
	
	public GameObject menuContainer;
	
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnClick()
	{
		if(string.IsNullOrEmpty(nicknameInput.value))
		{
			NotificationManager.instance.Show(NotificationManager.Type.NickName, 2.5f);
		}
		else if( GameManager.SelectedPower == Power.Type.None)
		{
			NotificationManager.instance.Show(NotificationManager.Type.Power, 2.5f);
		}
		else
		{
			PlayerPrefs.SetString("Nickname", nicknameInput.value);
			menuContainer.SendMessage("CloseMenu");
			
			Invoke("LaunchNow", 0.5f);
			//Application.LoadLevel("Game");
		}
		
		
	}
	
	void LaunchNow()
	{
		Application.LoadLevel("Game");
	}
	
}
